﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Zor_DAL;
using Zor_Tools;

namespace Zor_Bll
{
    public class TenantCompanyHousBrowse_Bll<T> where T : class
    {
        /// <summary>
        /// 获取租户[企业]信息列表
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="TotalCount">返回值</param>
        /// <returns></returns>
        public static List<T> GetPageList(dynamic Model, int index,string where ,out int TotalCount)
        {
            int Dtid = RequestSession.GetSessionUser().DT_Id;
            int Isadmin = RequestSession.GetSessionUser().Is_Admin;
            var sqlSurch = " 1=1 ";
            if (Isadmin == 1 || Dtid == 16)
            {
                sqlSurch = " 1=1 ";
            }
            else
            {
                sqlSurch = "( StreetOfficeID = " + Dtid + " or Dt_ParentId = " + Dtid + " )";
            }
            if (Model.StreetOffice != null)
            {
                sqlSurch += " and " + " StreetOffice like '%" + Model.StreetOffice + "%'  ";
            }
            if (Model.Community != null)
            {
                sqlSurch += " and " + " Community like '%" + Model.Community + "%'  ";
            }
            if (Model.Tenant_Name != null)
            {
                sqlSurch += " and " + " Tenant_Name like '%" + Model.Tenant_Name + "%'  ";
            }
            if (Model.Tenant_TaxRegistrationNum != null)
            {
                sqlSurch += " and " + " Tenant_TaxRegistrationNum = '" + Model.Tenant_TaxRegistrationNum + "'  ";
            }
            if (Model.Tenant_Phone != null)
            {
                sqlSurch += " and " + " Tenant_Phone like '%" + Model.Tenant_Phone + "%'  ";
            }
            if (Model.Tenant_LegalPerson != null)
            {
                sqlSurch += " and " + " Tenant_LegalPerson like '%" + Model.Tenant_LegalPerson + "%'  ";
            }
            if (Model.Ept_Industry != null)
            {
                sqlSurch += " and " + " Ept_Industry like '%" + Model.Ept_Industry + "%'  ";
            }
            if (Model.Tenant_ScopeBusiness != null)
            {
                sqlSurch += " and " + " Tenant_ScopeBusiness like '%" + Model.Tenant_ScopeBusiness + "%'  ";
            }
            if (Model.Tenant_Code != null)
            {
                sqlSurch += " and " + " Tenant_Code like '%" + Model.Tenant_Code + "%'  ";
            }
            return PagerHelp<T>.GetPagerList(index, "V_TenantCompanyHousBrowse", "Community", out TotalCount, sqlSurch);
        }
    }
}
